Skip to content

feat(cli): vouch new <kind> — scaffold a typed page/entity proposal (closes #330)#346

Open
e11734937-beep wants to merge 2 commits into
vouchdev:mainfrom
e11734937-beep:feat/vouch-new-scaffold
Open

feat(cli): vouch new <kind> — scaffold a typed page/entity proposal (closes #330)#346
e11734937-beep wants to merge 2 commits into
vouchdev:mainfrom
e11734937-beep:feat/vouch-new-scaffold

Conversation

@e11734937-beep

@e11734937-beep e11734937-beep commented Jul 3, 2026

Copy link
Copy Markdown

Summary

Closes #330. Adds vouch new <kind> — scaffolds a typed page or entity proposal from its registered shape, so an author gets a correctly-shaped draft instead of hand-writing --meta pairs and discovering required fields only when propose-page rejects them.

It reads load_page_kind_registry(store) for the kind, stubs every required field, and files a pending proposal via the existing propose_page / propose_entity calls — no new kb.* method, no storage.py logic, no server/JSONL registration. Just the CLI command in src/vouch/cli.py plus tests/test_new_scaffold.py.

Surface

  • vouch new <kind> --title <t> for page kinds; --name <n> for entity kinds.
  • --field key=value (repeatable, YAML-parsed through the same _parse_meta path as --meta on propose-page).
  • --interactive/-i — prompt for each unfilled required field (default off, so runs stay scriptable).
  • --body <t> / --body - (stdin), --dry-run, --json, --claim/--source, --alias/--description.
  • Deterministic dispatch: a registered page kind scaffolds a page; --entity forces the entity path; a name that is only an EntityType scaffolds an entity; the decision/project collisions resolve to page unless --entity; an unknown kind fails listing the known page kinds and entity types.

Review gate & validation (design note)

The scaffold never weakens validation. It calls propose_page(..., proposed_by=_whoami()) exactly as propose-page does, so the same page_kinds and dangling-reference checks run. Because propose_page re-validates (_is_missing treats an empty value as missing), a required field left empty is flagged the same way any other proposal is — you fill it via --field/--interactive, or see it listed in --dry-run. --dry-run assembles and prints the draft (title, kind, stubbed frontmatter, missing-required list) and files nothing. A required_citations kind surfaces a citation reminder rather than silently proposing an uncited page. The scaffolded artifact is pending-only — a human still runs vouch approve <id> to land it.

(If the intent of "proposable but flagged" was to file a pending proposal even with empty required fields rather than surface the validation error, that's a one-line change — happy to adjust; I defaulted to faithfully reusing propose_page's existing validation.)

Tests

tests/test_new_scaffold.py covers page scaffold (create with required filled), dry-run stubbing (no write), unfilled-required flagging, --field YAML parsing, entity scaffold routing, collision dispatch (decision → page; --entity → entity), unknown-kind error, and pending-only.

Verification

  • python -m ruff check src tests — clean
  • python -m mypy src — clean
  • python -m pytest — full suite green (8 new tests; no regressions)

Summary by CodeRabbit

  • New Features

    • Added a new vouch new command to scaffold pending proposals for page or entity kinds.
    • Supports --dry-run, --json, interactive filling of missing required fields, and --field key=value YAML parsing.
    • Handles page citations/reminders when required, and reads page body from standard input when provided via --body -.
  • Bug Fixes

    • Improved validation and kind routing for ambiguous names, including honoring the entity flag to force entity scaffolding.
    • Unknown kinds now return clearer errors and list available kinds.

Closes vouchdev#330.

Add `vouch new <kind>`: read the page-kind registry (or EntityType) for
KIND, stub every required field, and file a pending proposal through the
normal review gate — composing the existing propose_page / propose_entity
calls, with no new kb.* method, storage logic, or server registration.
@github-actions github-actions Bot added cli command line interface tests tests and fixtures size: M 200-499 changed non-doc lines labels Jul 3, 2026
@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ab228a7c-ccfd-4dee-b155-b1938178013b

📥 Commits

Reviewing files that changed from the base of the PR and between aa8b8b3 and adbba13.

📒 Files selected for processing (1)
  • src/vouch/cli.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/vouch/cli.py

📝 Walkthrough

Walkthrough

Adds a new vouch new <kind> CLI command that scaffolds pending page or entity proposals. Page scaffolding reads registry requirements, parses --field YAML, handles missing fields and citations, and supports dry-run output; entity scaffolding validates --name and files through propose_entity. End-to-end tests cover both paths.

Changes

vouch new scaffold command

Layer / File(s) Summary
Command declaration and dispatch
src/vouch/cli.py
Imports EntityType, declares the new command, and routes kinds deterministically between page and entity targets with mismatch errors.
Entity scaffolding
src/vouch/cli.py
Validates --name, supports dry-run/JSON output, and creates pending entity proposals through propose_entity.
Page scaffolding
src/vouch/cli.py
Validates --title, reads body input, resolves required fields and citation requirements from the registry, parses --field YAML, fills missing fields, and creates pending page proposals through propose_page.
Scaffold tests
tests/test_new_scaffold.py
Adds the fixture and CLI tests for page scaffolding, dry-run behavior, validation failures, YAML parsing, entity routing, collision handling, unknown kinds, and pending-only filing.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Author
  participant CLI as vouch new
  participant Registry as PageKindRegistry
  participant Proposals as propose_page/propose_entity
  participant Store as KBStore

  Author->>CLI: vouch new <kind> [flags]
  CLI->>Registry: resolve(kind)
  alt entity path
    CLI->>Proposals: propose_entity(store, ...)
  else page path
    CLI->>CLI: parse fields, fill missing values
    CLI->>Proposals: propose_page(store, ..., dry_run?)
  end
  Proposals->>Store: create pending proposal
  Store-->>CLI: proposal id
  CLI-->>Author: print id or draft
Loading

Possibly related PRs

  • vouchdev/vouch#333: Implements the same vouch new <kind> CLI scaffolding flow and overlapping test coverage for page/entity routing.

Suggested labels: docs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding a typed vouch new scaffold command for page/entity proposals.
Linked Issues check ✅ Passed The changes match the linked issue: registry-based page scaffolding, entity routing, dry-run, YAML field parsing, citations reminder, and pending proposals.
Out of Scope Changes check ✅ Passed The PR appears scoped to the requested CLI scaffold command and its tests, with no obvious unrelated code changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
tests/test_new_scaffold.py (2)

41-126: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Missing coverage for --interactive prompting and required_citations reminder.

The PR objectives call out two behaviors that have no corresponding test here: --interactive prompting for missing required fields, and a citation reminder surfaced for kinds with required_citations. Consider adding tests for both to lock in the documented behavior.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/test_new_scaffold.py` around lines 41 - 126, Add test coverage in
test_new_scaffold for the two missing scaffold behaviors: the CliRunner-based
`new` command should prompt for absent required fields when `--interactive` is
used, and kinds declared with `required_citations` should surface a reminder in
the output. Reuse the existing scaffolding helpers like `_declare_kind`, `cli`,
and `store.get_proposal` to assert the interactive path fills or requests
missing required data, and verify the citation reminder appears for the affected
kind.

1-1: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

File name doesn't mirror the module under test.

This suite tests the new command added to src/vouch/cli.py, but the file is named test_new_scaffold.py rather than test_cli.py. As per coding guidelines, "Test file names must mirror module names using the tests/test_<module>.py convention."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/test_new_scaffold.py` at line 1, The test file name does not match the
module under test, so rename the suite to follow the tests/test_<module>.py
convention for src/vouch/cli.py. Update the test filename from
test_new_scaffold.py to the corresponding cli-focused name so it clearly mirrors
the module being exercised, and keep the existing test contents unchanged.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/vouch/cli.py`:
- Around line 1098-1101: The page-kind registry lookup in the CLI setup is
happening outside the existing _cli_errors() handling, so invalid page-kind
configuration can still surface a traceback and stop entity-only scaffolds. Move
the load_page_kind_registry(store) and subsequent
registry.known()/registry.resolve(kind) usage into the _cli_errors() block in
the vouch new flow, and keep the exception handling focused there rather than
adding PageKindError separately since it already inherits ValueError.

---

Nitpick comments:
In `@tests/test_new_scaffold.py`:
- Around line 41-126: Add test coverage in test_new_scaffold for the two missing
scaffold behaviors: the CliRunner-based `new` command should prompt for absent
required fields when `--interactive` is used, and kinds declared with
`required_citations` should surface a reminder in the output. Reuse the existing
scaffolding helpers like `_declare_kind`, `cli`, and `store.get_proposal` to
assert the interactive path fills or requests missing required data, and verify
the citation reminder appears for the affected kind.
- Line 1: The test file name does not match the module under test, so rename the
suite to follow the tests/test_<module>.py convention for src/vouch/cli.py.
Update the test filename from test_new_scaffold.py to the corresponding
cli-focused name so it clearly mirrors the module being exercised, and keep the
existing test contents unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b95783b5-a956-4f87-bd3f-8746d09ce694

📥 Commits

Reviewing files that changed from the base of the PR and between 5f58c69 and aa8b8b3.

📒 Files selected for processing (2)
  • src/vouch/cli.py
  • tests/test_new_scaffold.py

Comment thread src/vouch/cli.py
load_page_kind_registry() and registry.resolve() ran outside the
_cli_errors() handler in `vouch new`, so an invalid page_kinds config
surfaced a raw traceback and could block entity-only scaffolds. Move the
registry load/known()/resolve() calls inside _cli_errors() so PageKindError
(already a ValueError subclass) is translated to a clean CLI error. Success
path is unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@e11734937-beep

Copy link
Copy Markdown
Author

Hi @plind-junior,

Thanks for building vouch — nice to see a tool aimed squarely at the SN74 contribution loop.

I have two PRs open that are waiting on first-time-contributor approval before CI can run:

Both are ready for review. I verified them locally against the CI gates — ruff check src tests, mypy src, and pytest --cov all pass — the CodeRabbit threads are resolved, and each is scoped to a single feature with tests.

Whenever you get a moment, would you mind approving the workflow run and taking a look?

Happy to adjust anything to fit the repo conventions.

Thanks!

@e11734937-beep

Copy link
Copy Markdown
Author

Hi @plind-junior — following up on #346 and #347: they are still waiting on first-contributor CI approval before the checks can run. Both are ready — I verified them locally against the CI gates (ruff check src tests, mypy src, and pytest --cov all pass), the CodeRabbit threads are resolved, and each is scoped to a single feature with tests. Would you mind approving the workflow run when you get a moment? Happy to adjust anything to fit the repo conventions. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli command line interface size: M 200-499 changed non-doc lines tests tests and fixtures

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: vouch new <kind> — scaffold a typed page/entity proposal from a template

1 participant